package com.query;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class OperationLogQueryLink extends BaseQueryComplex {

    private String managerName;
    private Integer type;
    private Date minCreated;
    private Date maxCreated;

    @Override
    protected void init() {
        if (StringUtils.isNotBlank(managerName)) {
            params.put("managerName", "%" + managerName + "%");
        }
        if (null != type) {
            params.put("type", type);
        }
        if (null != minCreated) {
            params.put("minCreated", minCreated);
        }
        if (null != maxCreated) {
            params.put("maxCreated", maxCreated);
        }
    }

    @Override
    public String sortOrder() {
        return "T0.created DESC";
    }

    public String getManagerName() {
        return managerName;
    }

    public void setManagerName(String managerName) {
        this.managerName = managerName;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getMinCreated() {
        return minCreated;
    }

    public void setMinCreated(Date minCreated) {
        this.minCreated = minCreated;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public Date getMaxCreated() {
        return maxCreated;
    }

    public void setMaxCreated(Date maxCreated) {
        this.maxCreated = maxCreated;
    }
}